package com.qf.device.controller;

import com.qf.core.dto.PageDto;
import com.qf.core.vo.PageResult;
import com.qf.core.vo.R;
import com.qf.device.dto.DeviceDto;
import com.qf.device.entity.Device;
import com.qf.device.service.DeviceService;
import com.qf.product.entity.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 设备表 前端控制器
 * </p>
 *
 * @author zhu
 * @since 2023-10-26
 */
@RestController
@CrossOrigin
@RequestMapping("/device")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    @PostMapping("/page")
    public PageResult<Device> page(@RequestBody PageDto<DeviceDto> pageDto) {
        return deviceService.findPage(pageDto);
    }

    @PostMapping("/delete/{id}")
    public R delete(@PathVariable String id){

        return deviceService.deleteDevice(id);
    }

    @GetMapping("/list")
    public R all(){
        return deviceService.selectActive();
    }


}
